{{if $data and $data|is_array}}{{$ret = array()}}{{foreach $data as $x}}{{if !$x|is_array}}{{$ret[] = $x->toArray()}}{{else}}{{$ret[] = $x}}{{/if}}{{/foreach}}{{$data = $ret}}{{/if}}
{{if $data and !$data|is_array}}{{$data = $data->fetchAll()}}{{$ret = array()}}{{foreach $data as $x}}{{if !$x|is_array}}{{$ret[] = $x->toArray()}}{{/if}}{{/foreach}}{{$data = $ret}}{{/if}}
{{if !$data}}{{$data = array()}}{{/if}}
{{$slug = null}}
{{if $value|default}}
{{foreach $value as $index => $v}}
{{if $slug ne $v->category_id}}
{{if $slug}}
</select>
{{if $mode eq 1}}
{{include file='form/category.form.child.tpl'}}
{{/if}}
</td>
</tr>
{{/if}}
{{$slug = $v->category_id}}
{{$mode = $v->mode}}
<tr>
<th>{{$v->name}} {{$mode}}</th>
{{if $mode eq 1}}
<td class="form_multiple_input" et_value="{{$v->category_id}}" et_count="{{$data|count}}">
{{if !$confirm|default}}
<input type="button" value="{{$smarty.config.add}}" class="add" disabled="disabled" />
{{/if}}
<select name="_{{$v->slug}}" {{if $confirm|default}}style="display:none"{{/if}}>
{{else}}
<td>
{{if $mode eq 0 OR $mode eq 2}}
<input type="hidden" name="_category[a{{$v->category_id}}][category_id]" value="{{$v->category_id}}" />
<input type="hidden" name="_category[a{{$v->category_id}}][parameter_1]" value="1" />
<input type="hidden" name="_category[a{{$v->category_id}}][slug]" value="{{$v->slug}}" />
{{/if}}
{{if $mode eq 0}}{{if !$confirm|default}}
<select name="_category[a{{$v->category_id}}][category_list_id]">
{{/if}}{{/if}}
{{/if}}
{{/if}}
{{if $mode eq 1}}
<option value="{{$v->category_list_id}}" et_value="{{$v->param_count}}" et_mode="{{$v->slug}}">{{$v->note}}</option>
{{else if $mode eq 2}}
<label><input type="radio" value="{{$v->category_list_id}}" name="_category[a{{$v->category_id}}][category_list_id]" {{foreach $data as $x}}{{if $x.category_list_id|default eq $v->category_list_id}}checked="checked"{{/if}}{{/foreach}} />{{$v->note}}</label>
{{else if $mode eq 3}}
<input type="hidden" name="_category[a{{$v->category_id}}b{{$v->category_list_id}}][category_id]" value="{{$v->category_id}}" />
<input type="hidden" name="_category[a{{$v->category_id}}b{{$v->category_list_id}}][parameter_1]" value="1" />
<input type="hidden" name="_category[a{{$v->category_id}}b{{$v->category_list_id}}][slug]" value="{{$v->slug}}" />
{{if !$confirm|default}}
<label><input type="checkbox" value="{{$v->category_list_id}}" name="_category[a{{$v->category_id}}b{{$v->category_list_id}}][category_list_id]" {{foreach $data as $x}}{{if $x.category_list_id|default eq $v->category_list_id}}checked="checked"{{/if}}{{/foreach}} />{{$v->note}}</label>
{{else}}
{{foreach $data as $x}}{{if $x.category_list_id|default eq $v->category_list_id}}
<label><input type="hidden" value="{{$v->category_list_id}}" name="_category[a{{$v->category_id}}b{{$v->category_list_id}}][category_list_id]" checked="checked" />{{$v->note}}</label>
{{/if}}{{/foreach}}
{{/if}}
{{else}}
{{if !$confirm|default}}
<option value="{{$v->category_list_id}}" {{foreach $data as $x}}{{if $x.category_list_id|default && $x.category_list_id && $x.category_list_id eq $v->category_list_id}}selected="selected"{{/if}}{{/foreach}}>{{$v->note}}</option>
{{else}}{{foreach $data as $x}}{{/foreach}}{{foreach $data as $x}}{{if $x.category_list_id|default eq $v->category_list_id}}
{{$v->note}}
<input type="hidden" name="_category[a{{$v->category_id}}][category_list_id]" value="{{$v->category_list_id}}" />
{{/if}}{{/foreach}}{{/if}}
{{/if}}
{{if $index eq $value->rowCount()-1}}
{{if $mode eq 1}}
</select>
{{else if $mode eq 0}}{{if !$confirm|default}}
</select>
{{/if}}
{{/if}}
{{if $mode eq 1}}
{{include file='form/category.form.child.tpl'}}
{{/if}}
</td>
</tr>
{{/if}} 
{{/foreach}}
{{/if}}